import './css/weui.css'; 
import './css/public.css';  
import common from './common/common.js'; 

let get = common.GET(); 
$(function (){
	if (get['type']) {
		$("#listTitle").text(get['type']);
		$.get(`../data/${get['type']}.json`,function(data){
			console.log(data);
			let tData = data.subjects;
			let items = '';
			tData.forEach((item) =>{
				items += `<a href="./subject.html?id=${item.id}" class="weui-media-box weui-media-box_appmsg">
				                    <div class="weui-media-box__hd">
				                        <img class="weui-media-box__thumb" src="${item.images.medium}" alt="">
				                    </div>
				                    <div class="weui-media-box__bd">
				                        <h4 class="weui-media-box__title">${item.title}</h4>
				                        <p class="weui-media-box__desc">
				                        		<div class="desc">${item.original_title}(${item.year})</div>
				                        		<div class="desc">${item.directors[0].name}</div>
				                        </p>
				                    </div>
				                    <div class="weui-media-box__bd rating" style="flex;0.2">
							${item.rating.average}
				                    </div>
				                </a>`;
			});
			$("#listBox").html(items);
			setTimeout(() => {
				$("#loadingToast").toggleClass("boxout");
				setTimeout(() => $("#loadingToast").css("display","none"),1000);
			},1000);
		});
	} 
});
